package com.yht.weblog.admin.controller;

import com.yht.weblog.admin.model.vo.tag.AddTagReqVO;
import com.yht.weblog.admin.model.vo.tag.DeleteTagReqVO;
import com.yht.weblog.admin.model.vo.tag.FindTagPageListReqVO;
import com.yht.weblog.admin.model.vo.tag.SearchTagReqVO;
import com.yht.weblog.admin.service.AdminTagService;
import com.yht.weblog.common.aspect.ApiOperationLog;
import com.yht.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: yht
 * @date: 2024/1/1 11:07
 * @description: 标签管理模块
 **/
@RestController
@RequestMapping("/admin")
@Api(tags = "标签管理模块")
public class AdminTagController {

    @Autowired
    private AdminTagService adminTagService;

    /**
     * 添加标签
     * @param AddTagReqVO
     * @return
     */
    @PostMapping("/tag/add")
    @ApiOperation(value = "添加标签")
    @ApiOperationLog(description = "添加标签")
    public Response addTag(@RequestBody @Validated AddTagReqVO AddTagReqVO) {
        return adminTagService.addTags(AddTagReqVO);
    }

    /**
     * 查询标签列表数据
     * @param findTagPageListReqVO
     * @return
     */
    @PostMapping("/tag/list")
    @ApiOperation(value = "查询标签分页数据")
    @ApiOperationLog(description = "查询标签分页数据")
    public Response findTagPageList(@RequestBody @Validated FindTagPageListReqVO findTagPageListReqVO) {
        return adminTagService.findTagPageList(findTagPageListReqVO);
    }

    /**
     * 删除标签
     * @param deleteTagReqVO
     * @return
     */
    @PostMapping("/tag/delete")
    @ApiOperation(value = "删除标签")
    @ApiOperationLog(description = "删除标签")
    public Response deleteCategory(@RequestBody @Validated DeleteTagReqVO deleteTagReqVO) {
        return adminTagService.deleteTag(deleteTagReqVO);
    }

    /**
     * 标签模糊查询
     * @param searchTagReqVO
     * @return
     */
    @PostMapping("/tag/search")
    @ApiOperation(value = "标签模糊查询")
    @ApiOperationLog(description = "标签模糊查询")
    public Response searchCategory(@RequestBody @Validated SearchTagReqVO searchTagReqVO) {
        return adminTagService.searchTag(searchTagReqVO);
    }
    /**
     * 查询标签下拉列表数据
     * @return
     */
    @PostMapping("/tag/select/list")
    @ApiOperation(value = "查询标签下拉列表数据")
    @ApiOperationLog(description = "查询标签下拉列表数据")
    public Response findTagSelectList(){
        return adminTagService.findTagSelectList();
    }
}
